#ifndef BSP_DBUS_H
#define BSP_DBUS_H

#include "stm32f4xx.h"
#include "stdio.h"
#include "bsp_dbus.h"
#include "usart.h"

typedef struct {
	
	struct {
		uint16_t ch[5];
		unsigned char s[2];
	} rc;
	
	struct {
		uint16_t x, y, z, press_l, press_r;
	} mouse;
	
	struct {
		uint16_t v;
	} key;
} RC_ctrl_t;

extern RC_ctrl_t rc_ctl;
extern uint8_t rx_buf[18];
extern DMA_HandleTypeDef hdma_usart3_rx;

void controller_init(void);
void USART3_IDLE_IQR(void);
void sbus_to_rc(volatile const uint8_t *sbus_buf, RC_ctrl_t *rc_ctrl);

#endif
